package com.dexing.od2;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class D0303Matrix {

    public static int[] entrances = new int[2];
    public static int count = 0;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int n = scanner.nextInt();

        String[][] matrix = new String[m][n];
        scanner.nextLine();
        for (int i = 0; i < m; i++) {
            String[] s = scanner.nextLine().split(" ");
            for (int j = 0; j < n; j++) {
                matrix[i][j] = s[j];
            }
        }
        
        //最大的区域大小
        int result = 0;
        List<int[]> emptyZones = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (matrix[i][j].equals("O")) {
                    matrix[i][j] = "X";
                    // 空区域坐标集合
                    ArrayList<int[]> coords = new ArrayList<>();
                    coords.add(new int[]{i,j});
                    findZone(m,n,i,j,coords,matrix);
                    if (count ==1 ) {
                        // 有大小相同的单入口区域，只要大小。无需坐标
                        if (result == coords.size()) {
                            emptyZones.clear();
                        } else if (result < coords.size()) {
                            emptyZones.clear();
                            emptyZones.add(new int[]{entrances[0],entrances[1],coords.size()});
                            result = coords.size();
                        }
                    }
                    // 重置入口数量
                    count = 0;
                    // 重置入口坐标
                    entrances = new int[2];
                }
            }
            // 输出
            if (emptyZones.size() ==1) {
                int[] ints = emptyZones.get(0);
                System.out.println(ints[0]+" "+ints[1]+" "+ints[2]);
            } else if (result != 0) {
                System.out.println(result);
            } else {
                System.out.println("NULL");
            }
        }
    }

    private static void findZone(int m, int n, int i, int j, ArrayList<int[]> coords, String[][] matrix) {
        // 边界
        if (i == 0 || i == m-1 || j == 0 || j == n -1) {
            count++;
            entrances[0] =  i;
            entrances[1] = j;
        }

        // 往右或往下遍历
        if (i < m-1) {
            if (matrix[i+1][j].equals("O")) {
                matrix[i+1][j]="X";
                coords.add(new int[]{i+1, j});
                findZone(m,n,i+1,j,coords,matrix);
            }
        }
        if (j < n-1) {
            if (matrix[i][j+1].equals("O")) {
                matrix[i][j+1]="X";
                coords.add(new int[]{i, j+1});
                findZone(m,n,i,j+1,coords,matrix);
            }
        }
    }
}
